//---------------------------------------------------------------------------

#ifndef sample_httpH
#define sample_httpH

#include "sckt/sckt.hpp"
#include "http_cookie/http_cookie.h"
#include "http_postdata/http_postdata.h"
#include <string>

class sample_http {
        public:
                sample_http();
                ~sample_http();
                std::string Get(std::string url);
                std::string Post(std::string url, http_postdata pd);

                //-- Settings ---
                bool CookieEnable;
                bool HeaderEnable;
                bool RedirectEnable;
                //-----
                int http_result_code;
                std::string http_redirect_url;
                //-----
        private:
                sckt::Library *http_lib;
                sckt::TCPSocket *http_socket;
                sckt::IPAddress http_ip;
                http_cookie cookie;

                std::string http_header;
                std::string http_url;

                bool Connect(std::string uri,int port);
                void Disconnect();
                void ClearData();
                bool ChekProto(std::string url);
                std::string GetUri(std::string url);
                std::string MakeHeader(std::string url);
                std::string MakePostheader(std::string url, http_postdata pd);
                bool SendData(std::string data);
                bool RecvData(std::string &recv_data);
                void ParseHeader(std::string &recv_data);
                void FindRedirect(std::string header);
                int get_result_code(std::string content);

};


#endif
